home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 30
/
Aminet 30 (1999)(Schatztruhe)[!][Apr 1999].iso
/
Aminet
/
util
/
time
/
backclock.lha
/
BackClock
/
sources
/
timer.c
< prev
next >
Wrap
C/C++ Source or Header
|
1998-10-17
|
1KB
|
50 lines
/*****************************************************************************
*
* Nom: timer.c
* Desc: handle timer
*
*
* version : $VER: timer.c 1.1 (17.10.98)
*****************************************************************************
*/
#include <proto/exec.h>
#include <devices/timer.h>
#include "utils.h"
#include "timer.h"
int initTimer(idWin * prj) {
// retourne TRUE si initialisation ok
int ret = FALSE ;
prj->timerok = FALSE ; // ok (pour le refermer)
if ((prj->trport = CreateMsgPort()) != NULL) {
// creation port message ok
if ((prj->treq = CreateIORequest(prj->trport, sizeof(struct timerequest))) != NULL) {
// creation ioreq ok
if (!OpenDevice(TIMERNAME, UNIT_VBLANK, (struct IORequest*)prj->treq, 0)) {
// ouverture timer ok
ret = TRUE ;
prj->timerok = TRUE ;
}
}
}
return ret ;
}
void closeTimer(idWin * prj) {
if (prj->timerok)
CloseDevice((struct IORequest*)prj->treq) ;
if (prj->treq)
DeleteIORequest(prj->treq) ;
if (prj->trport)
DeleteMsgPort(prj->trport) ;
}
void runtimer(idWin * prj, long seconds) {
/* lance le timer
*/
if (prj->timerok) {
prj->treq->tr_time.tv_secs = seconds ;
prj->treq->tr_time.tv_micro = NULL ;
prj->treq->tr_node.io_Command = TR_ADDREQUEST ;
SendIO((struct IORequest *)prj->treq) ;
}
}